Skip to content

Add actix-web seller example to validate actix integration#7

Merged
takasaki404 merged 4 commits intofeat/actix-web-supportfrom
copilot/sub-pr-6
Feb 24, 2026
Merged

Add actix-web seller example to validate actix integration#7
takasaki404 merged 4 commits intofeat/actix-web-supportfrom
copilot/sub-pr-6

Conversation

Copy link
Contributor

Copilot AI commented Feb 24, 2026

Adds x402-kit/examples/actix_web_seller.rs to demonstrate actix-web paywall middleware patterns, mirroring the existing axum_seller.rs example.

Changes

  • Standard paywallhandle_payment() flow via middleware::from_fn
  • Custom paywall — Step-by-step API (process_request → settle → run_handler)
  • Multi-payment paywall — Accepts both EVM and SVM payment schemes

Key integration pattern

Actix-web's ServiceRequest/ServiceResponse types are bridged to the paywall's HttpRequest/HttpResponse traits by splitting and reconstructing:

async fn standard_paywall(
    req: ServiceRequest,
    next: Next<impl MessageBody + 'static>,
) -> Result<ServiceResponse<impl MessageBody>, Error> {
    let (http_req, payload) = req.into_parts();
    let http_req_clone = http_req.clone();

    let response = paywall
        .handle_payment(http_req, |http_req| async move {
            let srv_req = ServiceRequest::from_parts(http_req, payload);
            match next.call(srv_req).await {
                Ok(res) => res.map_into_boxed_body().into_parts().1,
                Err(err) => err.error_response().map_into_boxed_body(),
            }
        })
        .await
        .map_err(Error::from)?;

    Ok(ServiceResponse::new(http_req_clone, response))
}

State is passed via app_data::<web::Data<AppState>>() and PaymentState is read from request extensions using the HttpMessage trait.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits February 24, 2026 11:28
Co-authored-by: takasaki404 <193405421+takasaki404@users.noreply.github.com>
Co-authored-by: takasaki404 <193405421+takasaki404@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for actix-web integration Add actix-web seller example to validate actix integration Feb 24, 2026
Copilot AI requested a review from takasaki404 February 24, 2026 11:33
@takasaki404 takasaki404 marked this pull request as ready for review February 24, 2026 11:41
@takasaki404 takasaki404 merged commit f05aaac into feat/actix-web-support Feb 24, 2026
17 checks passed
@takasaki404 takasaki404 deleted the copilot/sub-pr-6 branch February 24, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants